package com.huanwei.read;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.huanwei.cc.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**+
 * 每日一讀詳情
 */
public class web_Activity extends AppCompatActivity {

    @BindView(R.id.img_back)
    RelativeLayout imgBack;
    @BindView(R.id.webview)
    WebView mWebView;
    @BindView(R.id.activity_web_)
    LinearLayout activityWeb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_);
        ButterKnife.bind(this);
        String id = getIntent().getStringExtra("id");
        Log.e("8888", id);

        mWebView.requestFocus();//触摸焦点起作用mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);//取消滚动条
        mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);//设置允许js弹出alert对话框

//load在线
        mWebView.loadUrl(id);

//设置了Alert才会弹出，重新onJsAlert（）方法return true可以自定义处理信息
        mWebView.setWebChromeClient(new WebChromeClient() {
            @Override
            public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
//return super.onJsAlert(view, url, message, result);
                Toast.makeText(web_Activity.this, message, Toast.LENGTH_LONG).show();
                return true;
            }
        });


    }

    @OnClick(R.id.img_back)
    public void onViewClicked() {
        finish();
    }
}
